//
//  PersonSex.m
//  timelyRain
//
//  Created by Jiafei Wei on 2016/12/23.
//  Copyright © 2016年 Jiafei Wei. All rights reserved.
//

#import "PersonSex.h"

@interface PersonSex ()<UIGestureRecognizerDelegate>{
    NSString *sexValue;
}
@property (weak, nonatomic) IBOutlet UIView *man;
@property (weak, nonatomic) IBOutlet UIView *women;
@property (weak, nonatomic) IBOutlet UIImageView *manchoose;
@property (weak, nonatomic) IBOutlet UIImageView *womenchoose;

@end

@implementation PersonSex

- (void)viewDidLoad {
    [super viewDidLoad];
    [super setTitleView:self.view withName:@"性别"];
    [self chooseMan];
    [self chooseWoMan];
    if ([_sexText isEqualToString:@"0"]) {
            _manchoose.hidden=NO;
            _womenchoose.hidden=YES;
            sexValue =@"男";
    }else if([_sexText isEqualToString:@"1"]){
            _manchoose.hidden=YES;
            _womenchoose.hidden=NO;
            sexValue =@"女";
    }else{
            _manchoose.hidden=NO;
            _womenchoose.hidden=YES;
            sexValue =@"男";
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:YES];
    if (sexValue==nil) {
        sexValue=@"男";
    }
    NSNotification * notice = [NSNotification notificationWithName:@"setting_data" object:nil userInfo:@{@"data":sexValue,@"type":@"sex"}];
    [[NSNotificationCenter defaultCenter]postNotification:notice];
}
-(void)chooseMan{
    _man.userInteractionEnabled = YES;
    UITapGestureRecognizer *addTapGest = [[UITapGestureRecognizer alloc] init];
    addTapGest.numberOfTapsRequired = 1;
    addTapGest.delegate = self;
    [_man addGestureRecognizer:addTapGest];
    [addTapGest addTarget:self action:@selector(rightTapView:)];
}
- (void)rightTapView:(UITapGestureRecognizer *)addTapGest{
    //选男
    _manchoose.hidden=NO;
    _womenchoose.hidden=YES;
    sexValue =@"男";
}
-(void)chooseWoMan{
    _women.userInteractionEnabled = YES;
    UITapGestureRecognizer *addTapGest = [[UITapGestureRecognizer alloc] init];
    addTapGest.numberOfTapsRequired = 1;
    addTapGest.delegate = self;
    [_women addGestureRecognizer:addTapGest];
    [addTapGest addTarget:self action:@selector(rightTapView1:)];
}
- (void)rightTapView1:(UITapGestureRecognizer *)addTapGest{
    _manchoose.hidden=YES;
    _womenchoose.hidden=NO;
     sexValue =@"女";
}
@end
